Properly update internal state when child visibility changes. (#331785,
authorMatthias Clasen <mclasen@redhat.com>
Mon, 20 Feb 2006 23:11:55 +0000 (23:11 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 20 Feb 2006 23:11:55 +0000 (23:11 +0000)
2006-02-20  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtknotebook.c: Properly update internal state
        when child visibility changes.  (#331785, Sebastien Bacher)

ChangeLog
ChangeLog.pre-2-10
gtk/gtknotebook.c

index 5589ba333fa13412f90827521fe7aafd126a0106..30487f4ec31bceb1257ae0ee17b94a86e6c32b3c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2006-02-20  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtknotebook.c: Properly update internal state
+       when child visibility changes.  (#331785, Sebastien Bacher)
+
        * gdk/gdkgc.c (_gdk_gc_update_context): Obtain the
        background color from the gc when it is needed.  (#331820)
 
index 5589ba333fa13412f90827521fe7aafd126a0106..30487f4ec31bceb1257ae0ee17b94a86e6c32b3c 100644 (file)
@@ -1,5 +1,8 @@
 2006-02-20  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtknotebook.c: Properly update internal state
+       when child visibility changes.  (#331785, Sebastien Bacher)
+
        * gdk/gdkgc.c (_gdk_gc_update_context): Obtain the
        background color from the gc when it is needed.  (#331820)
 
index 4e1d8584d9f5200fa99f6b6728baadb7bda8b6d1..5f114166dd4ab967bed94d0618da5e523fccb727 100644 (file)
@@ -112,7 +112,8 @@ struct _GtkNotebookPage
   GtkRequisition requisition;
   GtkAllocation allocation;
 
-  guint mnemonic_activate_signal;
+  gulong mnemonic_activate_signal;
+  gulong notify_visible_handler;
 };
 
 #ifdef G_DISABLE_CHECKS
@@ -2714,6 +2715,8 @@ gtk_notebook_real_remove (GtkNotebook *notebook,
 
   page = list->data;
   
+  g_signal_handler_disconnect (page->child, page->notify_visible_handler); 
+
   if (GTK_WIDGET_VISIBLE (page->child) && GTK_WIDGET_VISIBLE (notebook))
     need_resize = TRUE;
 
@@ -4326,6 +4329,33 @@ gtk_notebook_mnemonic_activate_switch_page (GtkWidget *child,
   return TRUE;
 }
 
+
+static void
+page_visible_cb (GtkWidget  *page,
+                 GParamSpec *arg,
+                 gpointer    data)
+{
+  GtkNotebook *notebook = (GtkNotebook *)data;
+  GList *list;
+  GList *next = NULL;
+
+  if (notebook->cur_page &&
+      notebook->cur_page->child == page &&
+      !GTK_WIDGET_VISIBLE (page))
+    {
+      list = g_list_find (notebook->children, notebook->cur_page);
+      if (list)
+        {
+          next = gtk_notebook_search_page (notebook, list, STEP_NEXT, TRUE);
+          if (!next)
+            next = gtk_notebook_search_page (notebook, list, STEP_PREV, TRUE);
+        }
+
+      if (next)
+        gtk_notebook_switch_page (notebook, GTK_NOTEBOOK_PAGE (next), -1);
+    }
+}
+
 /**
  * gtk_notebook_insert_page_menu:
  * @notebook: a #GtkNotebook
@@ -4432,6 +4462,8 @@ gtk_notebook_insert_page_menu (GtkNotebook *notebook,
       gtk_notebook_switch_focus_tab (notebook, NULL);
     }
 
+  page->notify_visible_handler = g_signal_connect (G_OBJECT (child), "notify::visible",                                            G_CALLBACK (page_visible_cb), notebook);
+
   gtk_notebook_update_tab_states (notebook);
 
   if (tab_label)